<?php
	include("project.class.php");
	$project = new Project();
	
	@ $submit = $_POST['submit'];
		
	if(isset($submit)){
		@ $check1 = $project->checkDate($_POST['deadline'],"dmY",".");
		@ $check2 = $project->checkDate($_POST['deadline'],"Ymd","-");
		
		
		if(($check1 == false || $check2 == false)&&!is_numeric($_POST['budget'])){
			echo "<font color=red>Datum & Budget im falschen Format</font>";
		}else if($check1 == false|| !$check2 == false){
			echo "<font color=red>Datum im falschen Format</font>";
		}else if(!is_numeric($_POST['budget'])){
			echo "<font color=red>Budget im falschen Format</font>";
		}else{
			$project -> createProject(
					$_POST['projectname'],
					$_POST['deadline'],
					$_POST['budget']);
		}		
		
}

	

?>

<form action="<?php $_SERVER['PHP_SELF']?>" method="post">
	<table>
		<tr>
			<td>Projektname:</td>
			<td><input type="text" name="projectname" /></td>
			<td></td>
			
		</tr>
		<tr>
			<td>Deadline:</td>
			<td><input type="date" name="deadline" /></td>
			<td></td>
			
		</tr>

		<tr>
			<td>Budget:</td>
			<td><input type="number" name="budget" /></td>
			<td>EUR</td>
			
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" name="submit" value="Eintragen"/></td>
			<td></td>

		</tr>
	</table>

</form>